class Solution
{
public:
    int maxSubArray(vector<int>& nums)
    {
        vector<int> dp(nums.size() + 1);
        int ret = INT_MIN;
        for (int i = 1; i <= nums.size(); i++)
        {
            dp[i] = max(nums[i - 1], dp[i - 1] + nums[i - 1]);
            ret = max(dp[i], ret);
        }
        return ret;
    }
};